/*****************************************************************************/
/* File: Ball.h						                                         */
/* Author: rszulgo                                                           */
/*                                                                           */
/* Description:																 */
/* Representation of ball object.											 */
/*****************************************************************************/
#pragma once

#include "Drawable.h"
#include "Bat.h"
#include "Level.h"
#include "Common.h"
#include "Model.h"

class CBall : public CDrawable
{
public:
	CBall();
	~CBall(void);

	int Draw();
	int Update();

	float GetSpeed() { return m_fSpeed; }
	void SetSpeed(float fSpeed) { m_fSpeed = fSpeed; }
	float GetRadius() { return m_fRadius; }

	int BatHit(CBat* pBat);		//called when ball hits a bat
	int BatBounce(CBat* pBat);	// called when ball need to rebound after hitting a bat
	int BonusHit();				// bonus hit
	int Out(CBat* pBat);		// ball out on the owner of pBat side - set it as trapped
	int Trap(CBat* pBat, float fXOffset);	// set ball as trapped with z offset


	void SetRecent(CBat* pBat) { m_pBatRecent = pBat; }
	CBat* GetRecent() { return m_pBatRecent; }

	void SetSurface(GLfloat fSurface[4]) { for(int i=0; i<4; i++) m_fBallSurface[i] = fSurface[i]; }

	int GetType(){return TYPE_BALL;}

	static void SetModel(CModel* pModel) { m_pModel = pModel; }

	static void EnableClone(bool bEnable) { m_bEnableClone = bEnable; }

private:
	float m_fSpeed;	
	float m_fRadius;			//ball radius
	CBat* m_pBatRecent;			//poiter to bat that was touched recently
	GLfloat m_fBallSurface[4];	//surface
	bool m_bTrapped;			//true if ball is "trapped" by player. pointer to player set in BatRecent
	float m_fXTrapOffset;		//offset from center pf a bat when ball is trapped

	//float m_fTimeToClone;		//timer that counts down time to clone the ball
	static bool m_bEnableClone;

	static CModel* m_pModel;	//3D model

};
